home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Picture Viewer / Source / PictureViewerUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-08  |  6.5 KB  |  278 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.     File:        PictureViewerUtils.h
  3.     
  4.     Contains:    Interfaces of utility routines and classes.
  5.  
  6.     Written by:    Sue Dumont            [based on SamplePart by Steve Smith]
  7.  
  8.     Copyright:    © 1994-95 by Apple Computer, Inc., all rights reserved.
  9. ------------------------------------------------------------------------------*/
  10.  
  11. #ifndef _PICTUREVIEWERUTILS_
  12. #define _PICTUREVIEWERUTILS_
  13.  
  14.  
  15. // --- PictureViewer Includes ---
  16.  
  17. #ifndef _SAMPLECOLLECTIONS_
  18. #include "SampleCollections.h"
  19. #endif
  20.  
  21. // --- OpenDoc Includes ---
  22.  
  23. #ifndef _ODTYPES_
  24. #include <ODTypes.h>
  25. #endif
  26.  
  27. // -- OpenDoc Utilities --
  28.  
  29. #ifndef _ITEXT_
  30. #include <IText.h>
  31. #endif
  32.  
  33. #ifndef _ODDEBUG_
  34. #include <ODDebug.h>
  35. #endif
  36.  
  37. #ifndef _ODUTILS_
  38. #include <ODUtils.h>
  39. #endif
  40.  
  41. // --- Macintosh Includes ---
  42.  
  43. #ifndef __QDOFFSCREEN__
  44. #include <QDOffscreen.h>
  45. #endif
  46.  
  47.  
  48. // --- Forward Declarations ---
  49.  
  50. class ODDraft;
  51. class ODFacet;
  52. class ODWindow;
  53. class ODStorageUnitView;
  54.  
  55.  
  56. //------------------------------------------------------------------------------
  57. // Function Prototypes
  58. //------------------------------------------------------------------------------
  59.  
  60. ODIText*        GetPartName(Environment* ev, ODPart* part, ODType category);
  61. ODBoolean        NamesAreEquivalent(Environment* ev, ODIText* fileName,
  62.                                         ODIText* partName);
  63.  
  64. void            GetEditorScriptLanguage(Environment* ev, ODScriptCode* script,
  65.                                         ODLangCode* language);
  66.  
  67. GWorldPtr         BeginGWorldThumbnail(CGrafPtr* savePort, GDHandle* saveGDevice);
  68. void            EndGWorldThumbnail(CGrafPtr savePort, GDHandle saveGDevice);
  69. void            DrawGWorldThumbnail(Environment* ev, GWorldPtr gwPtr, ODFacet* facet);
  70.  
  71. ODHandle        Read1IndResource(ResType type, short index);
  72.  
  73. ODUShort        CountFacets(Environment* ev, ODFrame* frame);
  74. Rect            TilePartWindow(Environment* ev, Rect* facetBounds, Rect* PartWindowBounds);
  75.  
  76. void            FixedToIntRect(ODRect& fixedRect, Rect& intRect);
  77. void            IntToFixedRect(Rect& intRect, ODRect& fixedRect);
  78.  
  79. //------------------------------------------------------------------------------
  80. // Utility Class Definitions
  81. //------------------------------------------------------------------------------
  82.  
  83. class CFrameProxy
  84. {
  85.     public:
  86.     CFrameProxy();
  87.     ~CFrameProxy();
  88.     
  89.     void        InitFrameProxy(ODID frameID, ODDraft* draft);
  90.     void        InitFrameProxy(Environment* ev, ODFrame* frame);
  91.     void        Purge(Environment* ev);
  92.  
  93.     ODFrame*    GetFrame(Environment* ev);
  94.     void        SetFrame(Environment* ev, ODFrame* frame);
  95.     ODBoolean    FrameIsLoaded(Environment* ev);
  96.     ODID        GetID();
  97.     ODDraft*    GetDraft();
  98.     
  99.     private:
  100.     ODFrame*    fFrame;
  101.     ODID        fID;
  102.     ODDraft*    fDraft;
  103. };
  104.  
  105. class CFrameInfo
  106. {
  107.     public:
  108.             CFrameInfo(ODSession* session);
  109.             ~CFrameInfo();
  110.     
  111.     void    Externalize(Environment* ev, ODStorageUnitView* storageUnitView);
  112.     void    CleanseFrameInfoProperty(Environment* ev, ODStorageUnit* storageUnit);
  113.     void    ExternalizeFrameInfo(Environment* ev, ODStorageUnit* storageUnit,
  114.                                     ODDraftKey key, ODFrame* scopeFrame);
  115.     void    CloneInto(Environment *ev, ODDraftKey key,
  116.                                     ODStorageUnitView* storageUnitView,
  117.                                     ODFrame* scopeFrame);
  118.     void    InitFromStorage(Environment* ev, ODStorageUnitView* storageUnitView);
  119.                 
  120.     ODBoolean        IsFrameActive();
  121.     void            SetFrameActive(ODBoolean active);
  122.     ODBoolean        FrameNeedsReactivating();
  123.     void            SetFrameReactivate(ODBoolean reactivate);
  124.     ODFacet*        GetActiveFacet();
  125.     void            SetActiveFacet(ODFacet* facet);
  126.     void            SetSourceFrame(Environment* ev, ODFrame* frame);
  127.     ODFrame*        GetSourceFrame(Environment* ev);
  128.     void            ReleaseSourceFrame(Environment* ev);
  129.     ODBoolean        HasSourceFrame();
  130.     ODWindow*        AcquirePartWindow(Environment* ev);
  131.     void            SetPartWindow(Environment* ev, ODWindow* window);
  132.     void            SetDependentFrame(Environment* ev, ODFrame* frame);
  133.     ODFrame*        GetDependentFrame(Environment* ev);
  134.     ODBoolean        HasDependentFrame();
  135.     void            ReleaseDependentFrame(Environment* ev);
  136.     ODBoolean        GetNegotiationFlag();
  137.     void            SetNegotiationFlag(ODBoolean flag);
  138.     void            SetShouldDisposeWindow(ODBoolean should);
  139.     ODBoolean        ShouldDisposeWindow();
  140.     
  141.     private:
  142.     CFrameInfo(); /* don't want parts to call */
  143.     
  144.     ODSession*        fSession;
  145.     ODBoolean        fFrameActive;
  146.     ODBoolean        fFrameReactivate;
  147.     ODBoolean        fShouldDisposeWindow;
  148.     ODBoolean        fIsNegotiated;
  149.     ODFacet*        fActiveFacet;
  150.     CFrameProxy*    fSourceFrame;
  151.     CFrameProxy*    fDependentFrame;
  152.     ODID            fPartWindowID;
  153. };
  154.  
  155. //-------------------------------------------------------------------------
  156. // Inline methods
  157. //-------------------------------------------------------------------------
  158.  
  159. //=========================================================================
  160. // CFrameProxy
  161. //=========================================================================
  162.  
  163. inline CFrameProxy::CFrameProxy()
  164. {
  165.     fFrame = kODNULL;
  166.     fID = kODNULLID;
  167.     fDraft = kODNULL;
  168. }
  169.  
  170. inline CFrameProxy::~CFrameProxy()
  171. {
  172.     ODSafeReleaseObject(fFrame);
  173. }
  174.     
  175. inline void CFrameProxy::InitFrameProxy(ODID frameID, ODDraft* draft)
  176. {
  177.     ASSERT(draft!=kODNULL, kODErrIllegalNullInput);
  178.     
  179.     fFrame = kODNULL;
  180.     fID = frameID;
  181.     fDraft = draft;
  182. }
  183.     
  184. inline void CFrameProxy::InitFrameProxy(Environment* ev, ODFrame* frame)
  185. {
  186.     ASSERT(frame!=kODNULL, kODErrIllegalNullFrameInput);
  187.     
  188.     this->SetFrame(ev,frame);
  189. }
  190.  
  191. inline ODID CFrameProxy::GetID()
  192. {
  193.     return fID;
  194. }
  195.  
  196. inline ODDraft* CFrameProxy::GetDraft()
  197. {
  198.     return fDraft;
  199. }
  200.  
  201. //=========================================================================
  202. // CFrameInfo
  203. //=========================================================================
  204.  
  205. inline ODBoolean CFrameInfo::IsFrameActive()
  206. {
  207.     return fFrameActive;
  208. }
  209.  
  210. inline void CFrameInfo::SetFrameActive(ODBoolean active)
  211. {
  212.     fFrameActive = active;
  213. }
  214.  
  215. inline ODBoolean CFrameInfo::FrameNeedsReactivating()
  216. {
  217.     return fFrameReactivate;
  218. }
  219.  
  220. inline void CFrameInfo::SetFrameReactivate(ODBoolean reactivate)
  221. {
  222.     fFrameReactivate = reactivate;
  223. }
  224.  
  225. inline ODFacet* CFrameInfo::GetActiveFacet()
  226. {
  227.     return fActiveFacet;
  228. }
  229.  
  230. inline void CFrameInfo::SetActiveFacet(ODFacet* facet)
  231. {
  232.     fActiveFacet = facet;
  233. }
  234.  
  235. inline ODFrame* CFrameInfo::GetSourceFrame(Environment* ev)
  236. {
  237.     return (fSourceFrame->GetFrame(ev));
  238. }
  239.  
  240. inline ODBoolean CFrameInfo::HasSourceFrame()
  241. {
  242.     return (fSourceFrame != kODNULL);
  243. }
  244.  
  245. inline ODFrame* CFrameInfo::GetDependentFrame(Environment* ev)
  246. {
  247.     return (fDependentFrame->GetFrame(ev));
  248. }
  249.  
  250. inline ODBoolean CFrameInfo::HasDependentFrame()
  251. {
  252.     return (fDependentFrame != kODNULL);
  253. }
  254.  
  255. inline ODBoolean CFrameInfo::GetNegotiationFlag()
  256. {
  257.     return fIsNegotiated;
  258. }
  259.  
  260. inline void CFrameInfo::SetNegotiationFlag(ODBoolean flag)
  261. {
  262.     fIsNegotiated = flag;
  263. }
  264.  
  265. inline void CFrameInfo::SetShouldDisposeWindow(ODBoolean should)
  266. {
  267.     fShouldDisposeWindow = should;
  268. }
  269.  
  270. inline ODBoolean CFrameInfo::ShouldDisposeWindow()
  271. {
  272.     return fShouldDisposeWindow;
  273. }
  274.  
  275. #endif
  276.  
  277.  
  278.